import { createWebHashHistory, createRouter } from 'vue-router'
import layout from '@/layout/index.vue'
import storeRouter from './modules/store.js'
import nprogress from 'nprogress' // @types/nprogress
import 'nprogress/nprogress.css'

const routes = [
  {
    path: '/',
    component: layout,
    children: [
      {
        path: '',
        name: 'home',
        meta: { title: '首页' },
        component: () => import('@/views/home/index.vue')
      }
    ]
  },
  storeRouter
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

router.beforeEach(() => {
  nprogress.start() // 开始加载进度条
})

router.afterEach(() => {
  nprogress.done() // 加载进度条
})

export default router
